import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const TunnelInfos = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: false,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === 'dbddc567-656d-40e7-923c-599da6490dda') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, rules: true },
            commonTableList.fullName,
            { ...commonTableList.code, rules: true },
            { ...commonTableList.sortId, rules: true },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'totalLen',
                title: '隧道总长度',
                valueType: 'inputNumber',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'completeLen',
                title: '隧道完成长度',
                valueType: 'inputNumber',
                rules: true,
                width: 150,
            },

            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '8f54021b-f35f-4a26-95c0-d7e53411290c') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === 'bdcb55dd-9445-4437-98eb-438ced4be724') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
